package com.example.demo.conf;

import com.example.demo.service.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Author bsy
 * @Description   拦截器注入适配器
 * @Date 2022/8/15 23:21
 * @Version 1.0
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")//拦截所有的路径
                .excludePathPatterns("/LoginController/*");//配置不需要拦截的路径。
                //.excludePathPatterns("/index/hello");//配置多个路径。
    }

}
